//
//  AY_ReadBottomTool.m
//  AiYue
//
//  Created by mac on 2023/10/19.
//

#import "AY_ReadBottomTool.h"
#import "AY_ReadBookModel.h"

@interface AY_ReadBottomTool()
@property (strong, nonatomic) YButton *muluToolBtn;
@property (strong, nonatomic) YButton *yejianToolBtn;
@property (strong, nonatomic) YButton *setToolBtn;
@property (strong, nonatomic) UIView *setToolView;

@property (strong, nonatomic) UIView *lightView;
@property (strong, nonatomic) UIView *fanyeView;

@property (strong, nonatomic) UILabel *lightLabel;
@property (strong, nonatomic) UISlider *lightSlider;
@property (strong, nonatomic) UIButton *huyanBtn;
@property (strong, nonatomic) UILabel *zihaoLabel;
@property (strong, nonatomic) UIButton *jianBtn;
@property (strong, nonatomic) UIButton *jiaBtn;
@property (strong, nonatomic) UILabel *backColorLabel;
@property (strong, nonatomic) UIButton *backColorBtn;

@property (strong, nonatomic) UILabel *fanyeLabel;
@property (strong, nonatomic) UIButton *fanyeBtn;
@property (strong, nonatomic) UILabel *jianjuLabel;
@property (strong, nonatomic) UIButton *jianjuBtn;

@property (strong, nonatomic) NSMutableArray *colors;
@property (strong, nonatomic) NSArray *fanyes;
@property (assign, nonatomic) NSInteger selectColor;
@end

@implementation AY_ReadBottomTool

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self getData];
        [self addSubview:self.setToolView];
        [self addSubview:self.fanyeView];
        [self addSubview:self.lightView];
        [self initUI];
        [self setLightSubViews];
        [self setFanyeViews];
        [self setColors];
    }
    return self;
}

- (void)getData {
    self.colors = [NSMutableArray array];
    self.colors = [AY_ReadManager getThemes];
    self.fanyes = @[@"无",@"仿真",@"覆盖",@"上下翻页",@"上下滚动"];
}

#pragma mark - 护眼
- (void)huyan:(UIButton *)btn {
    btn.selected = !btn.selected;
    if (btn.selected) {
        [AYMMKV setFloat:0.2 forKey:HuYanAlpha];
    }else {
        [AYMMKV setFloat:0 forKey:HuYanAlpha];
    }
    if ([self.delegate respondsToSelector:@selector(huyanAction:)]) {
        [self.delegate huyanAction:btn];
    }
}

- (void)lightValue:(UISlider *)slider {
    [AYMMKV setFloat:0.5 - slider.value forKey:Brightness];
    if ([self.delegate respondsToSelector:@selector(brightnessChange)]) {
        [self.delegate brightnessChange];
    }
}

#pragma mark - 字号
- (void)zihaoAction:(UIButton *)btn {
    int font = [AYMMKV getInt32ForKey:ReadFont defaultValue:23];
    if (btn.tag == 101) {
        if (font <= 12) {
            [AYMMKV setUInt32:12 forKey:ReadFont];
        }else {
            font = font - 2;
            [AYMMKV setUInt32:font forKey:ReadFont];
        }
    }else {
        if (font >= 34) {
            [AYMMKV setUInt32:34 forKey:ReadFont];
        }else {
            font = font + 2;
            [AYMMKV setUInt32:font forKey:ReadFont];
        }
    }
    if ([self.delegate respondsToSelector:@selector(fontChange)]) {
        [self.delegate fontChange];
    }
}

#pragma mark - 间距
- (void)jianjuAction:(UIButton *)btn {
    int lineSpace = [AYMMKV getInt32ForKey:ReadLineSpace defaultValue:8];
    if (btn.tag == 40) {
        if (lineSpace <= 8) {
            [AYMMKV setUInt32:8 forKey:ReadLineSpace];
        }else {
            lineSpace = lineSpace - 2;
            [AYMMKV setUInt32:lineSpace forKey:ReadLineSpace];
        }
    }else {
        if (lineSpace >= 20) {
            [AYMMKV setUInt32:20 forKey:ReadLineSpace];
        }else {
            lineSpace = lineSpace + 2;
            [AYMMKV setUInt32:lineSpace forKey:ReadLineSpace];
        }
    }
    if ([self.delegate respondsToSelector:@selector(fontChange)]) {
        [self.delegate fontChange];
    }
}

#pragma mark - 颜色
- (void)colorAction:(UIButton *)btn {
    self.selectColor = btn.tag;
    AY_ReadBookModel *bookModel = self.colors[btn.tag - 1];
    for (int i =0; i < btn.superview.subviews.count; i++) {
        UIButton *btn1 = btn.superview.subviews[i];
        if (btn1.tag != btn.tag && btn1.tag < 10) {
            btn1.layer.borderWidth = 0;
        }
    }
    btn.layer.borderWidth = 2;
    [AYMMKV setString:bookModel.readBackColor forKey:ReadBackColor];
    [AYMMKV setString:bookModel.readToolColor forKey:ReadToolBackColor];
    [AYMMKV setString:bookModel.readTitleColor forKey:ReadTitleColor];
    [AYMMKV setString:bookModel.readLineColor forKey:ReadLineColor];
    [self setColors];
    
    if ([self.delegate respondsToSelector:@selector(colorAction:)]) {
        [self.delegate colorAction:btn];
    }
}

- (void)colorAction:(UIButton *)btn WithTag:(NSInteger)tag {
    AY_ReadBookModel *bookModel = self.colors[tag];
    UIButton *btn3 = [self viewWithTag:self.selectColor];
    btn3.layer.borderWidth = 0;
    UIButton *btn1 = [self viewWithTag:1];
    UIButton *btn2 = [self viewWithTag:self.colors.count];
    if (tag == self.colors.count - 1) {
        btn1.layer.borderWidth = 0;
        btn2.layer.borderWidth = 2;
    }else {
        btn1.layer.borderWidth = 2;
        btn2.layer.borderWidth = 0;
    }
    
//    _selectColorBtn.layer.borderWidth = 0;
//    btn.layer.borderWidth = 1;
//    _selectColorBtn = btn;
    
    [AYMMKV setString:bookModel.readBackColor forKey:ReadBackColor];
    [AYMMKV setString:bookModel.readToolColor forKey:ReadToolBackColor];
    [AYMMKV setString:bookModel.readTitleColor forKey:ReadTitleColor];
    [AYMMKV setString:bookModel.readLineColor forKey:ReadLineColor];
    [self setColors];
    if ([self.delegate respondsToSelector:@selector(colorAction:)]) {
        [self.delegate colorAction:btn];
    }
}

- (void)menuAction:(UIButton *)btn {
    if (btn.tag == 22) {
        btn.selected = !btn.selected;
        self.lightView.hidden = !btn.selected;
        self.fanyeView.hidden = btn.selected;
    }else if (btn.tag == 20) {
        if ([self.delegate respondsToSelector:@selector(muluAction:)]) {
            [self.delegate muluAction:btn];
        }
    }else {
        if ([AYTool isNight]) {
            [self colorAction:self.backColorBtn WithTag:0];
        }else {
            [self colorAction:self.backColorBtn WithTag:self.colors.count - 1];
        }
    }
}

#pragma mark - 翻页
- (void)fanyeAction:(UIButton *)btn {
    [AYMMKV setInt64:btn.tag - 30 forKey:ReadFanYe];
    for (int i=0; i < btn.superview.subviews.count; i++) {
        UIButton *btn1 = btn.superview.subviews[i];
        if (btn1.tag >= 30 && btn1.tag < 40) {
            btn1.layer.borderColor = COLOR([AYMMKV getStringForKey:ReadLineColor defaultValue:@"EDE5D8"]).CGColor;
        }
    }
    btn.layer.borderColor = COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:@"422D10"]).CGColor;
    if ([self.delegate respondsToSelector:@selector(changePageType:)]) {
        [self.delegate changePageType:btn];
    }
}

- (void)setColors {
    AY_ReadBookModel *bookModel = self.colors[1];
    self.setToolView.backgroundColor = COLOR([AYMMKV getStringForKey:ReadToolBackColor defaultValue:bookModel.readToolColor]);
    self.lightView.backgroundColor = COLOR([AYMMKV getStringForKey:ReadToolBackColor defaultValue:bookModel.readToolColor]);
    self.fanyeView.backgroundColor = COLOR([AYMMKV getStringForKey:ReadToolBackColor defaultValue:bookModel.readToolColor]);
    self.lightLabel.textColor = COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]);
    [self.huyanBtn setTitleColor:COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]) forState:UIControlStateNormal];
    self.lightSlider.minimumTrackTintColor = COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]);
    self.lightSlider.maximumTrackTintColor = COLOR([AYMMKV getStringForKey:ReadLineColor defaultValue:bookModel.readLineColor]);
    self.zihaoLabel.textColor = COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]);
    [self.jiaBtn setTitleColor:COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]) forState:UIControlStateNormal];
    self.jiaBtn.layer.borderColor = COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]).CGColor;
    [self.jianBtn setTitleColor:COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]) forState:UIControlStateNormal];
    self.jianBtn.layer.borderColor = COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]).CGColor;
    self.backColorLabel.textColor = COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]);
    self.fanyeLabel.textColor = COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]);
    self.jianjuLabel.textColor = COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]);
    
    [self.muluToolBtn setTitleColor:COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]) forState:UIControlStateNormal];
    [self.yejianToolBtn setTitleColor:COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]) forState:UIControlStateNormal];
    [self.setToolBtn setTitleColor:COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]) forState:UIControlStateNormal];
    
    [self.muluToolBtn setImage:[AYTool isNight] ? YImage(@"AY_mulu_night") : YImage(@"AY_mulu") forState:UIControlStateNormal];
    [self.yejianToolBtn setImage:[AYTool isNight] ? YImage(@"AY_yejian_night") : YImage(@"AY_yeJian") forState:UIControlStateNormal];
    [self.setToolBtn setImage:[AYTool isNight] ? YImage(@"AY_set_night") : YImage(@"AY_set") forState:UIControlStateNormal];
    
    UIButton *btn = [self viewWithTag:40];
    UIButton *btn1 = [self viewWithTag:41];
    btn1.layer.borderColor = COLOR([AYMMKV getStringForKey:ReadLineColor defaultValue:bookModel.readLineColor]).CGColor;
    btn.layer.borderColor = COLOR([AYMMKV getStringForKey:ReadLineColor defaultValue:bookModel.readLineColor]).CGColor;
    [btn setImage:[AYTool isNight] ? YImage(@"AY_jianju_xiao_night") : YImage(@"AY_jianju_xiao") forState:UIControlStateNormal];
    [btn1 setImage:[AYTool isNight] ? YImage(@"AY_jianju_da_night") : YImage(@"AY_jianju_da") forState:UIControlStateNormal];
    
    int fanye = [AYMMKV getInt32ForKey:ReadFanYe defaultValue:1];
    for (int i =0; i < self.fanyes.count; i++) {
        UIButton *btn = [self viewWithTag:30+i];
        [btn setTitleColor:COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]) forState:UIControlStateNormal];
        btn.layer.borderColor = COLOR([AYMMKV getStringForKey:ReadLineColor defaultValue:bookModel.readLineColor]).CGColor;
        if (i == fanye) {
            btn.layer.borderColor = COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:bookModel.readTitleColor]).CGColor;
        }
    }
}

- (void)setFanyeViews {
    self.fanyeLabel = [AYTool createLabelWithFrame:CGRectZero andText:@"翻页" andTextColor:nil andBgColor:nil andFont:YFont(12) andLines:1 andRadius:0 andAddSubView:self.fanyeView];
    [self.fanyeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.fanyeView).offset(YNUM(20));
        make.top.equalTo(self.fanyeView).offset(YNUM(30));
    }];
    
    UIButton *lastBtn;
    for (int i =0; i < self.fanyes.count; i++) {
        int fanye = [AYMMKV getInt32ForKey:ReadFanYe defaultValue:1];
        self.fanyeBtn = [AYTool createButtonWithFrame:CGRectZero andTitle:self.fanyes[i] andFont:YFont(12) andTitleColor:COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:@"422D10"]) andBg:nil andImage:nil andBgImage:nil andTarget:self andAction:@selector(fanyeAction:) andRadius:YNUM(6) andAddSubView:self.fanyeView];
        self.fanyeBtn.tag = i + 30;
        self.fanyeBtn.layer.borderColor = COLOR([AYMMKV getStringForKey:ReadLineColor defaultValue:@"EDE5D8"]).CGColor;
        self.fanyeBtn.layer.borderWidth = 1;
        if (i == fanye) {
            self.fanyeBtn.layer.borderColor = COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:@"422D10"]).CGColor;
        }
        [self.fanyeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            if (lastBtn) {
                make.left.equalTo(lastBtn.mas_right).offset(YNUM(5));
            }else {
                make.left.equalTo(self.fanyeLabel.mas_right).offset(YNUM(15));
            }
            make.centerY.equalTo(self.fanyeLabel);
            make.height.mas_equalTo(YNUM(28));
            make.width.mas_equalTo(YNUM(56));
        }];
        lastBtn = self.fanyeBtn;
    }
    
    self.jianjuLabel = [AYTool createLabelWithFrame:CGRectZero andText:@"间距" andTextColor:nil andBgColor:nil andFont:YFont(12) andLines:1 andRadius:0 andAddSubView:self.fanyeView];
    [self.jianjuLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.fanyeLabel);
        make.top.equalTo(self.fanyeLabel.mas_bottom).offset(YNUM(33));
    }];
    
    UIButton *lastBtn1;
    for (int i =0; i < 2; i++) {
        self.jianjuBtn = [AYTool createButtonWithFrame:CGRectZero andTitle:nil andFont:YFont(14) andTitleColor:COLOR([AYMMKV getStringForKey:ReadTitleColor defaultValue:@"422D10"]) andBg:nil andImage:i == 0 ? YImage(@"AY_jianju_xiao") : YImage(@"AY_jianju_da") andBgImage:nil andTarget:self andAction:@selector(jianjuAction:) andRadius:YNUM(6) andAddSubView:self.fanyeView];
        self.jianjuBtn.tag = i + 40;
        self.jianjuBtn.layer.borderWidth = 1;
        [self.jianjuBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            if (lastBtn1) {
                make.left.equalTo(lastBtn1.mas_right).offset(YNUM(5));
            }else {
                make.left.equalTo(self.jianjuLabel.mas_right).offset(YNUM(20));
            }
            make.centerY.equalTo(self.jianjuLabel);
            make.height.mas_equalTo(YNUM(28));
            make.width.mas_equalTo(YNUM(56));
        }];
        lastBtn1 = self.jianjuBtn;
    }
}

- (void)setLightSubViews {
    self.lightLabel = [AYTool createLabelWithFrame:CGRectZero andText:@"亮度" andTextColor:nil andBgColor:nil andFont:YFont(12) andLines:1 andRadius:0 andAddSubView:self.lightView];
    [self.lightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(YNUM(20));
        make.top.equalTo(self).offset(YNUM(30));
    }];
    
    self.huyanBtn = [AYTool createButtonWithFrame:CGRectZero andTitle:@"   护眼模式" andFont:YFont(14) andTitleColor:nil andBg:nil andImage:YImage(@"AY_huyan") andBgImage:nil andTarget:self andAction:@selector(huyan:) andRadius:0 andAddSubView:self.lightView];
    [self.huyanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.lightLabel);
        make.right.equalTo(self).offset(-YNUM(20));
    }];
    
    self.lightSlider = [[UISlider alloc] init];
    [self.lightSlider addTarget:self action:@selector(lightValue:) forControlEvents:UIControlEventValueChanged];
    self.lightSlider.value = [AYMMKV getFloatForKey:Brightness defaultValue:0] + 0.5;
    [self.lightView addSubview:self.lightSlider];
    [self.lightSlider mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.lightLabel);
        make.left.equalTo(self.lightLabel.mas_right).offset(YNUM(20));
        make.right.equalTo(self.huyanBtn.mas_left).offset(-YNUM(58));
    }];
    
    self.zihaoLabel = [AYTool createLabelWithFrame:CGRectZero andText:@"字号" andTextColor:nil andBgColor:nil andFont:YFont(12) andLines:1 andRadius:0 andAddSubView:self.lightView];
    [self.zihaoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.lightLabel);
        make.top.equalTo(self.lightLabel.mas_bottom).offset(YNUM(33));
    }];
    
    self.jianBtn = [AYTool createButtonWithFrame:CGRectZero andTitle:@"A-" andFont:YFont(12) andTitleColor:nil andBg:nil andImage:nil andBgImage:nil andTarget:self andAction:@selector(zihaoAction:) andRadius:YNUM(18) andAddSubView:self.lightView];
    self.jianBtn.tag = 101;
    self.jianBtn.layer.borderWidth = 1;
    [self.jianBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.zihaoLabel);
        make.left.equalTo(self.zihaoLabel.mas_right).offset(YNUM(20));
        make.width.mas_equalTo(YNUM(135));
        make.height.mas_equalTo(YNUM(36));
    }];
    
    self.jiaBtn = [AYTool createButtonWithFrame:CGRectZero andTitle:@"A+" andFont:YFont(12) andTitleColor:nil andBg:nil andImage:nil andBgImage:nil andTarget:self andAction:@selector(zihaoAction:) andRadius:YNUM(18) andAddSubView:self.lightView];
    self.jiaBtn.tag = 102;
    self.jiaBtn.layer.borderWidth = 1;
    [self.jiaBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.zihaoLabel);
        make.left.equalTo(self.jianBtn.mas_right).offset(YNUM(20));
        make.width.mas_equalTo(YNUM(135));
        make.height.mas_equalTo(YNUM(36));
    }];
    
    self.backColorLabel = [AYTool createLabelWithFrame:CGRectZero andText:@"背景" andTextColor:nil andBgColor:nil andFont:YFont(12) andLines:1 andRadius:0 andAddSubView:self.lightView];
    [self.backColorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.lightLabel);
        make.top.equalTo(self.zihaoLabel.mas_bottom).offset(YNUM(40));
    }];
    
    UIButton *lastBtn;
    for (int i =0; i < self.colors.count; i++) {
        AY_ReadBookModel *bookModel = self.colors[i];
        self.backColorBtn = [AYTool createButtonWithFrame:CGRectZero andTitle:nil andFont:nil andTitleColor:nil andBg:COLOR(bookModel.readBackColor) andImage:nil andBgImage:nil andTarget:self andAction:@selector(colorAction:) andRadius:YNUM(17) andAddSubView:self.lightView];
        self.backColorBtn.tag = i + 1;
        self.backColorBtn.layer.borderColor = THEME_COLOR.CGColor;
        if ([bookModel.readBackColor isEqual:[AYMMKV getStringForKey:ReadBackColor defaultValue:@"F6EFDC"]]) {
            self.backColorBtn.layer.borderWidth = 2;
        }
        [self.backColorBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            if (lastBtn) {
                make.left.equalTo(lastBtn.mas_right).offset(YNUM(30));
            }else {
                make.left.equalTo(self.backColorLabel.mas_right).offset(YNUM(20));
            }
            make.centerY.equalTo(self.backColorLabel);
            make.width.height.mas_equalTo(YNUM(34));
        }];
        lastBtn = self.backColorBtn;
    }
}

- (void)initUI {
    
    self.muluToolBtn = [[YButton alloc] init];
    self.muluToolBtn.tag = 20;
    [self.muluToolBtn centerImageAndTitle:YNUM(10)];
    [self.muluToolBtn addTarget:self action:@selector(menuAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.muluToolBtn setTitle:@"目录" forState:UIControlStateNormal];
    self.muluToolBtn.titleLabel.font = YFont(12);
    [self.setToolView addSubview:self.muluToolBtn];
    [self.muluToolBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.setToolView).offset(((SCREEN_W/3) - YNUM(30))/2);
        make.centerY.equalTo(self.setToolView);
        make.width.mas_equalTo(YNUM(30));
        make.height.mas_equalTo(YNUM(70));
    }];
    
    self.yejianToolBtn = [[YButton alloc] init];
    self.yejianToolBtn.tag = 21;
    [self.yejianToolBtn centerImageAndTitle:YNUM(10)];
    [self.yejianToolBtn addTarget:self action:@selector(menuAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.yejianToolBtn setTitle:@"夜间" forState:UIControlStateNormal];
    self.yejianToolBtn.titleLabel.font = YFont(12);
    [self.setToolView addSubview:self.yejianToolBtn];
    [self.yejianToolBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.setToolView).offset((((SCREEN_W/3) - YNUM(30))/2) + (SCREEN_W/3));
        make.centerY.equalTo(self.setToolView);
        make.width.mas_equalTo(YNUM(30));
        make.height.mas_equalTo(YNUM(70));
    }];
    
    self.setToolBtn = [[YButton alloc] init];
    self.setToolBtn.tag = 22;
    [self.setToolBtn centerImageAndTitle:YNUM(10)];
    [self.setToolBtn addTarget:self action:@selector(menuAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.setToolBtn setTitle:@"设置" forState:UIControlStateNormal];
    self.setToolBtn.titleLabel.font = YFont(12);
    [self.setToolView addSubview:self.setToolBtn];
    [self.setToolBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.setToolView).offset((((SCREEN_W/3) - YNUM(30))/2) + (SCREEN_W/3)*2);
        make.centerY.equalTo(self.setToolView);
        make.width.mas_equalTo(YNUM(30));
        make.height.mas_equalTo(YNUM(70));
    }];
}

- (UIView *)lightView {
    if (!_lightView) {
        _lightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, self.mj_h - GK_SAFEAREA_BTM - YNUM(46))];
        _lightView.userInteractionEnabled = YES;
        _lightView.hidden = NO;
    }
    return _lightView;
}

- (UIView *)fanyeView {
    if (!_fanyeView) {
        _fanyeView = [[UIView alloc] initWithFrame:CGRectMake(0, YNUM(50), SCREEN_W, self.mj_h - GK_SAFEAREA_BTM - YNUM(96))];
        _fanyeView.userInteractionEnabled = YES;
        _fanyeView.hidden = YES;
        UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W, self.mj_h - GK_SAFEAREA_BTM - YNUM(96)) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(YNUM(13), YNUM(13))];
        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
        maskLayer.frame = _fanyeView.bounds;
        maskLayer.path = maskPath.CGPath;
        _fanyeView.layer.mask = maskLayer;
    }
    return _fanyeView;
}

- (UIView *)setToolView {
    if (!_setToolView) {
        _setToolView = [[UIView alloc] initWithFrame:CGRectMake(0, self.mj_h - GK_SAFEAREA_BTM - YNUM(46), SCREEN_W, YNUM(46) + GK_SAFEAREA_BTM)];
        _setToolView.userInteractionEnabled = YES;
    }
    return _setToolView;
}
@end
